package sixkey.config;

/**
 * ClassName:OssConfig
 * Package:sixkey.config
 * Description
 *
 * @Author:@wenxueshi
 * @Create:2023/6/6 - 0:10
 * @Version:v1.0
 */

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 阿里云oss图片上传文件配置
 */
@Data
@Component
public class OssConfig implements InitializingBean {

    // 读取配置文件中的内容
    @Value("${aliyun.oss.file.endpoint}")
    private String endpoint;
    @Value("${aliyun.oss.file.keyid}")
    private String keyId;
    @Value("${aliyun.oss.file.keysecret}")
    private String keySecret;
    @Value("${aliyun.oss.file.bucketname}")
    private String bucketName;

    // 在spring生命周期中 实例化->生成对象->属性填充后会进行afterPropertiesSet方法
    // 定义空开常用变量
    public static String END_POINT;
    public static String KEY_ID;
    public static String KEY_SECRET;
    public static String BUCKET_NAME;

    @Override
    public void afterPropertiesSet() throws Exception {
        END_POINT = endpoint;
        KEY_ID = keyId;
        KEY_SECRET = keySecret;
        BUCKET_NAME = bucketName;
    }
}
